package com.ts.controller.achievement;

import com.ts.constant.AchievementConstant;
import com.ts.dto.AcademicConferenceDTO;
import com.ts.result.Result;
import com.ts.service.achievement.AcademicConferenceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 学术会议相关接口 - 学术会议相关成果的提交，查询
 */
@RestController
@RequestMapping("/achievement/academicConference")
@Tag(name = "学术会议相关接口", description = "学术会议的提交和查询功能")
@Slf4j
public class AcademicConferenceController {

    @Autowired
    AcademicConferenceService academicConferenceService;

    /**
     * 提交一个学术会议类型成果
     * @param academicConferenceDTO
     * @return
     */
    @Operation(summary = "提交", description = "提交学术会议成果")
    @PostMapping()
    public Result saveAcademicConference(@RequestBody AcademicConferenceDTO academicConferenceDTO) {
        log.info("academicConferenceDTO:{}", academicConferenceDTO);
        //直接调用业务接口提交
        academicConferenceService.save(academicConferenceDTO);
        return Result.success();
    }

    /**
     * 根据ID查询学术会议详情
     */
    @Operation(summary = "根据ID查询", description = "根据ID查询学术会议详情")
    @GetMapping("/{id}")
    public Result<AcademicConferenceDTO> getById(@PathVariable Long id) {
        log.info("查询学术会议ID: {}", id);
        AcademicConferenceDTO conferenceDTO = academicConferenceService.getById(id);
        return Result.success(conferenceDTO);
    }

    /**
     * 更新学术会议
     */
    @Operation(summary = "更新", description = "更新学术会议")
    @PutMapping()
    public Result updateAcademicConference(@RequestBody AcademicConferenceDTO academicConferenceDTO) {
        log.info("更新学术会议: {}", academicConferenceDTO);
        academicConferenceService.update(academicConferenceDTO);
        return Result.success();
    }

    /**
     * 根据ID删除学术会议
     */
    @Operation(summary = "删除", description = "根据ID删除学术会议")
    @DeleteMapping("/{id}")
    public Result deleteAcademicConference(@PathVariable Long id) {
        log.info("删除学术会议ID: {}", id);
        academicConferenceService.delete(id);
        return Result.success();
    }
}
